const Controller = require("uni-cloud-router").Controller;
const {validateToken} = require('validdate-token');
module.exports = class UserController extends Controller{
	/**
	 * 根据用户名 获取用户数据
	 */
	async searchUserDataByName(){
		let {keyword,workStatus} = this.ctx.data;
		let reg = new RegExp(keyword.trim(), 'ig');
		
		let userDataResult = await this.db.collection('userdata').where({
			workStatus,
			name: reg
		}).get()
		
		if(userDataResult.affectedDocs !== 0 || userDataResult.data.length > 0){
			return {
				status:0,
				msg:"成功",
				data:userDataResult.data
			}
		} else {
			return {
				status:1,
				msg:"没有数据"
			}
		}
		
		return {
			status:-1,
			msg:"稍后重试"
		}
	}
}